<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>动态绑定内联样式——数据对象语法</title>
</head>
<body>
<div id="app">
    <!--动态绑定的时候，只有第一个生效-->
    <h1 v-bind:style="background" v-bind:style="fontSize">Hello, Vue!</h1>
    <h1 v-bind:style="fontSize" v-bind:style="background">Hello, Vue!</h1>

    <!--需要绑定多个样式对象的时候，不能在重新创建一个对象-->
    <h1 v-bind:style="obj">Hello, Vue!</h1>

    <h1 v-bind:style="[background, fontSize]">Hello, Vue!</h1>
    <h1 v-bind:style="style">Hello, Vue!</h1>
    <h1 v-bind:style="other">Hello, Vue!</h1>


</div>

<script type="module">
    import {createApp, ref, reactive} from "../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {
                let size = ref(64)
                let background =reactive({backgroundColor: 'red'})
                let fontSize = reactive({fontSize: size.value + 'px'})

                let obj = {background, fontSize}

                let style = reactive([background, fontSize])

                let other = reactive([{backgroundColor: 'red'}, {fontSize: size.value + 'px'}])


                return {
                    background, fontSize,obj,style, other
                }
            }
        }
    );

    app.mount("#app")
</script>
</body>
</html>